/**
 * Created by wzh on 2016/6/30.
 */
'use strict'
swan_pc
    .directive('traversalDatastruct',function($timeout,DateUtils){
        return {
            templateUrl:"scripts/services/directives/wzh/traversal/traversalDatastruct.html",
            scope: {
                infoStruct:"=",
                infoTraversal:"=",
                offset:"@",
                blockname:"@",
                dirtySet:"&",
                dirtyGet:"&",
                specialNeed:"@"
            },
            controller:['$scope', function($scope){
                $scope.tempDate=new Date("2000", "01", "01");
                $scope.bkWhite={
                    "background-color":"white"
                }
                $scope.bkGrey={
                    "background-color":"	#DAE7EB"
                }
                $scope.changeDate=function(infos,key,option) {
                    if (option==1) {
                        if(typeof(infos[key])!="string") return;
                        $scope.tempDate = DateUtils.convertLocaleDateFromServer(infos[key]);
                    }
                    else {
                        infos[key] = DateUtils.convertLocaleDateToServer($scope.tempDate);
                    }
                }
                $scope.getfocus=function (id){
                    if ($scope.specialNeed=="ReadOnly") return;
                    $timeout(function () {
                        document.getElementById(id).focus();
                    })
                }
                $scope.getValue=function (select,value){
                    var name="";
                    angular.forEach(select,function (data){
                        if(data.value==value) {
                            name=data.name;
                            return;
                        }
                    })
                    return name;
                }
            }]
        }
    })